﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YunSpace.Domain.Entity.MiniSite;
using YunSpace.Domain.IRepository.MiniSite;
using YunSpace.Domain.ViewModel.MiniSite;
using YunSpace.Repository.MiniSite;

namespace YunSpace.Application.MiniSite
{
    public class MessageRecordApp
    {
        private IMessageRecordRepository service = new MessageRecordRepository();

        /// <summary>
        /// 创建活动消息
        /// </summary>
        public MessageRecordEntity CreateActivitiyMessages(MessageRecordEntity entity)
        {
            entity.Create();
            // 消息类型;1:场地订单消息,2:活动订单消息,3:场地退款消息,4:活动退款消息
            entity.F_MessageType = 2;
            entity.F_IsRead = false;

            service.Insert(entity);

            return entity;
        }

        /// <summary>
        /// 创建场地消息
        /// </summary>
        public MessageRecordEntity CreateSiteMessages(MessageRecordEntity entity)
        {
            entity.Create();
            // 消息类型;1:场地订单消息,2:活动订单消息,3:场地退款消息,4:活动退款消息
            entity.F_MessageType = 1;
            entity.F_IsRead = false;

            service.Insert(entity);

            return entity;
        }

        /// <summary>
        /// 获取指定用户的活动消息列表
        /// </summary>
        //public List<ActivitiyMessageActionModel> GetActivitiyMessagesByCustomerId(string customerId, string lastId, int count = 10)
        public List<MessageRecordEntity> GetActivitiyMessagesByCustomerId(string customerId, int msgType, string lastId, int count)
        {
            
            return service.GetActivitiyMessages(customerId, msgType, lastId, count);
        }

        /// <summary>
        /// 获取指定用户所有消息
        /// </summary>
        public AllMessageActionModel GetAllMessageTotalByCustomerId(string customerId)
        {
            return service.GetAllMessage(customerId);
        }

        public bool UpdateActivitiyMessageStatus(string messageId) {
            return service.UpdateActivitiyMessageStatus(messageId);
        }
    }
}
